<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Pay extends CI_Controller {

	public function __construct()
    {
        parent::__construct();
        $this->load->model('Order_model');
    }
	
	//发起支付宝支付
	public function done()
	{
		$no = $this->input->get('no');
		$o = $this->Order_model->get_by_where(array("no"=>$no));
		if($o)
		{
			if ($o['paystatus'] == 2)
			{
				redirect('m/order/detail?id='._get_key_val($o['id']));
			}
			$param['trade_no'] = $o['no'];
			$param["subject"] = '魔步网工作订单';
			$param["total_fee"] = $o['total_fee'];
// 			$param['total_fee'] = 0.01;
			$param["body"] = $o['title'];
			$param["ordershow_url"] = "http://".$_SERVER['SERVER_NAME']."/m/order/detail?id="._get_key_val($o['id']);
			$this->load->service('alipay_service');
			$result = $this->alipay_service->alipay($param);
			echo $result;
				
				
				
// 				$oSysPaystatus = _get_config('get_paystatus');
// 				$this->Order_model->update_by_where(array('id'=>$id), array('paystatus'=>$oSysPaystatus[2]));

// 				redirect(base_url('/m/order'));
		}
	}

}